<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <button onclick="checkTest();">test</button>
</body>
<script type="text/javascript">
    /* 获取指定cookie */
    function getCookie(name) {
        var strCookie = document.cookie;
        var arrCookie = strCookie.split("; ");
        for (var i = 0; i < arrCookie.length; i++) {
            var arr = arrCookie[i].split("=");
            if (arr[0] == name)
                return arr[1];
        }
        return "";
    }
    function checkTest() {
        if (getCookie("user_identify") != "" && getCookie("user_name") != "") {
            var id = getCookie("user_identify"),
                name = getCookie("user_name");
            alert(id);
            alert(name);
        }else{
            alert("请登录！")
        }
    }
</script>
</html>